<?php
	require_once '../Tool/Common/PrepareInput.php';

    session_start();
    if (empty($_SESSION["userType"])) {
        $url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
    }
    
    $NRIC=$CustomerName=$SignInTimeStamp ="";      

    $result=array();

    $result['flagNRIC']=0;  
    $result['flagCustomerName']=0;
    $result['flagSignInTimeStamp']=0;

    if(isset($_REQUEST['NRIC'])) { 
        $NRIC=prepareInput($_REQUEST['NRIC']); 
    }
    if(isset($_REQUEST['CustomerName'])) { 
        $CustomerName=prepareInput($_REQUEST['CustomerName']); 
    }
    if(isset($_REQUEST['SignInTimeStamp'])) { 
        $SignInTimeStamp=prepareInput($_REQUEST['SignInTimeStamp']); 
    }
    
    if(!empty($NRIC)&&preg_match("/^[0-9A-Za-z]*$/",$NRIC)){
		$result['flagNRIC']=1;
	}
    if(empty($NRIC)){
        $result['flagNRIC']=1;
    }
    if(!empty($CustomerName)&&preg_match("/^[0-9A-Za-z.'' ]*$/",$CustomerName)){
        $result['flagCustomerName']=1;
    }
    if(empty($CustomerName)){
        $result['flagCustomerName']=1;
    }
    if(!empty($SignInTimeStamp)&&preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$SignInTimeStamp)){
        $result['flagSignInTimeStamp']=1;
    }
    if(empty($SignInTimeStamp)){
        $result['flagSignInTimeStamp']=1;
    }

    echo json_encode($result);
?>